package croppingplanap;

import java.awt.Color;
import java.util.Random;
import java.lang.Comparable;

public class Crop implements Comparable<Crop>{

	private Category category;
	private Color color;
	private String name;
	private int id;

	public static Crop NOTHING = new Crop("Nothing", null, -1, Color.getHSBColor(0,0,.85f));
	public static Crop COVER_CROP = new Crop("Cover Crop", Category.COVER_CROP, Category.COVER_CROP.getId(), Category.COVER_CROP.getNextColor());
	public static Crop RESEARCH = new Crop("Research", Category.RESEARCH, Category.RESEARCH.getId(), Category.RESEARCH.getNextColor());
	
	public Crop(String name, Category category, int id, Color color){
		this.category = category;
		this.name = name;
		this.color = color;
		this.id = id;
	}
	
	public static Color getRNDColor(){
		Random rnd = new Random();
		int[] n = new int[3];
		do{
			for(int i = 0 ; i < 3; i++){
				n[i] = rnd.nextInt(150) + 50;
			}
		}while(Math.abs(n[0] - n[1]) < 20 && Math.abs(n[1] - n[2]) < 20 && Math.abs(n[0] - n[2]) < 20);
		return new Color(n[0], n[1], n[2]);
	}
	
	public String toString(){
		return name;
	}
	
	public Category getCategory(){
		return category;
	}
	
	public Color getColor(){
		return color;
	}
	
	public int getId(){
		return id;
	}

	public int compareTo(Crop arg0) {
		return this.name.compareTo(arg0.name);
	}
	
}
